package webTest.sessionCookie.Session;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

/**
 * Created by IFT8 on 2015/1/22.
 *
 */
public class Pay extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("text/html;charset=utf-8");//设置为UTF-8编码
        HttpSession session= request.getSession();
        String id=(String)session.getAttribute("id");
        Goods goods=GoodsDAO.getGoods(id);
        if(goods!=null){
            response.getWriter().print("您正在为"+goods.getName()+"付款,金额为"+goods.getPrice()+"元。");
        }
    }
}
